package main

func BinarySearch(arr []int, len int, target int) int {
	// 在arr[l...r]之中查找target
	l, r := 0, len -1
	for l <= r {
		mid := (l + r) / 2
		if arr[mid] == target {
			return mid
		}
		if target < arr[mid] {
			r = mid - 1
		} else {
			l = mid + 1
		}
	}

	return -1
}

